<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "../inc/commonJs.html">
<script language="JavaScript">
	var grid;
	$(function() { 
		//分类管理表格  
		grid = $('#docgrid').datagrid({
		 width: 'auto',  
         height:'auto',             
         striped: true,  
         singleSelect : true,  
         url:'listDoc.do',  
         loadMsg:'数据加载中请稍后……',  
         pagination: true,  
         rownumbers: true, 
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
        columns:[[  
             {field:'docid',title: 'ID',align: 'center',width: '50'},  
             {field:'name',title: '名称',align: 'center',width: '250'},
             {field:'docClassName',title: '类别',align: 'center',width: '100'},
             {field:'userName',title: '上传人',align: 'center',width: '100'},
             {field:'deptName',title: '所属部门',align: 'center',width: '100'},
             {field:'dt',title: '上传时间',align: 'center',width: '150'},
             {field:'zt',title: '共享方式',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
             		if(value == '0'){
             			str = "不共享";
             		}else if(value == '1'){
             			str = "完全共享";
             		}else if(value == '2'){
             			str = "部门共享";
             		}
					return str;
				}
             },
             {field:'action',title: '操作',align: 'center',width: '100',
             	formatter: function(value,rowdata,index){
             		var str = '';
					str += '<a id="btnadd" class="l-btn l-btn-plain" target="_blank" href="${request.contextPath}/xadmin/work/docDownLoad.do?docid='+rowdata.docid+'"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left" >下载</span></span></a>';
					return str;
				}
             }]],
             toolbar : '#toolbar'
     });
		//
		$("#tree").tree({
		    method: "post",
		    lines: true,
		    url: "listDocClassForTree.do",
		    dataPlain: true,       //该属性用以启用当前 easyui-tree 控件对平滑数据格式的支持
		    toggleOnClick: false,
		    enableContextMenu: false,
		    onClick: function(node){
		        var params = {};
		        windowparam = node.id;
				params['classid'] = node.id;
				grid.datagrid('reload',params); 
			}
		});
		
  });
	function addDoc() {
		var modalwindow = window.top.modalwindow('${request.contextPath}/xadmin/work/docWindow.do',$('#docgrid'),{    
		    width:650,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'新增文档信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj('');
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	function editDoc() {
		var selected = $('#docgrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var modalwindow =  window.top.modalwindow('${request.contextPath}/xadmin/work/docWindow.do?docid='+selected.docid,$('#docgrid'),{    
		    width:650,    
		    height:250,
		    modal:true,
		    resizable:true,
		    title:'修改文档信息',
		    buttons:[{
				text:'保存',
				iconCls:"icon-save",
				handler:function(){
					modalwindow.find('iframe').get(0).contentWindow.saveObj(selected.docid);
				}
			},{
				text:'关闭',
				iconCls:"icon-cancel",
				handler:function(){
					modalwindow.dialog('close');
				}
			}]   
		});
	};
	
	//工具栏删除
	function delDoc(){
		var selected = $('#docgrid').datagrid('getSelected');
		if(!selected){
			window.top.$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		window.top.$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("${request.contextPath}/xadmin/work/delDoc.do", { "docid": selected.docid},
				   function(data){
				   	$('#docgrid').datagrid('reload'); 
				   	window.top.$.messager.alert('提示',data);
				   	
				});
			}
		});
	}
	function shenheDoc(id,result){
		if(result == 0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("${request.contextPath}/xadmin/work/shenheDoc.do", 
			{ "docid": id,"result":"zt="+result},
		   	function(data){
		   		$('#docgrid').datagrid('reload'); 
		   		window.top.$.messager.alert('提示',data);
		});
	}
	function restore(){
		$('#toolbar input').val('');
		$('#docgrid').datagrid('reload',{});
	}
	function dosearch(){
		var params = {};
		if($('#name').val()){
			params['name'] = '%'+$('#name').val()+'%';
		}
		if($('#userid').combobox('getValue')){
			params['userid'] = $('#userid').combobox('getValue');
		}
		if($('#zt').combobox('getValue')){
			params['zt'] = $('#zt').combobox('getValue');
		}
		$('#docgrid').datagrid('reload',params);
	}
</script>

</head>
<body class="easyui-layout">
<div data-options="region:'west',iconCls:'icon-mini-add',title:'按类型查找',split:true" style="width:180px;">
	<div class="easyui-panel" data-options='fit:true,border:false'> 
		<ul id="tree"></ul>
	</div>
</div>   
<div data-options="region:'center'">
<table id="docgrid" data-options="fit:true,border:false"></table>
</div>  

	<div id="toolbar" style="display: none;">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr >
				<td valign="center">
					&nbsp;&nbsp;文档名:
					<input  type="text" id="name" name="name" maxlength="30" style="width:150px;">
				</td>
				<td valign="center">
					&nbsp;&nbsp;上传人 :
					<input id="userid" class="easyui-combobox"  style="width:100px;" panelHeight:"auto" data-options="valueField:'userid',textField:'username',url:'${request.contextPath}/xadmin/system/listUserForCombox.do'" />
				</td>
				<td valign="center">
					&nbsp;&nbsp;状态: 
					<select id="zt" class="easyui-combobox" name="zt" style="width:100px;" panelHeight=80>
						<option></option>
					    <option value="0">不共享</option>   
					    <option value="1">完全共享</option>   
					    <option value="2">部门共享</option>   
					</select>
				</td>
				<td valign="center">	
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="dosearch();">搜索</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="restore();">重置</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addDoc();">增加</a>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="editDoc()">修改</a>
				</td>
				<td valign="center" align="left">
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="delDoc()">删除</a>
				</td>
				<td valign="center">
					<div class="datagrid-btn-separator"></div>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>